package databases

import (
	"database/sql"
	"fmt"
	_ "github.com/go-sql-driver/mysql"
	"video/api/config"
)

var (
	dbConn *sql.DB
	err error
)

func init()  {
	//dbConn, err = sql.Open(config.DRIVER_NAME, config.DATABASE_USER+":"+config.DATABASE_PWD+"@"+config.DATABASE_URL+"/"+config.DATABASE_TABLES+"?charset="+config.DATABASE_CODE)
	//dbConn, err = sql.Open(config.DRIVER_NAME,"root:root@tcp(127.0.0.1:3306)/video_server")
	dbConn, err = sql.Open(config.DRIVER_NAME,fmt.Sprintf("%s:%s@tcp(%s)/%s",config.DATABASE_USER,config.DATABASE_PWD,config.DATABASE_URL,config.DATABASE_TABLES))

	if err != nil{
		panic(err.Error())
	}

}